<style lang="less">
  @import "checkModel";
</style>

<template>
  <div class="checkModel">
    <div class="checkModel-search">
      <model-search @modelList="getResult"></model-search>
    </div>
    <div class="checkModel-table">
      <Table border stripe ref="selection" :columns="columns" :data="data"></Table>
    </div>
  </div>
</template>

<script>
  import ModelSearch from '../../../components/model-search/model-search'
    export default {
        name: "checkModel",
      components:{
        ModelSearch
      },
      data(){
        return{
          indeterminate: true,
          checkAll: false,
          styles: {
            height: 'calc(100% - 55px)',
            overflow: 'auto',
            paddingBottom: '53px',
            position: 'static'
          },
          modelData: {
            testSet:'',
            divide:0
          },
          columns: [
            {
              type: 'selection',
              width: 60,
              align: 'center'
            },
            { title:'ID',
              key:'id',
              width:90
            },
            {
              title: '模型名',
              key: 'name',
            },
            {
              title:'模型描述',
              key:'description'
            },
            {
              title: '创建者',
              key: 'creator'
            },
            {
              title:'类型',
              key:'type',
              width:120
            },
            {
              title:'状态',
              key:'state',
              width:120
            },
            {
              title: '操作',
              key: 'handle',
              width:90,
              render: (h, params) => {
                return h('div', [
                  //评估模型
                  h('Button', {
                    props: {
                      type:'primary'
                    },
                    style: {
                      marginRight: '5px'
                    },
                    on: {
                      click: () => {
                        this.evaluateModel()
                      }
                    }
                  },'评估')
                ]);
              }
            }
          ],
          data: [

          ]
        }
      },
      methods:{
        //获取查询模型的结果
        getResult(data){
          this.data=data;
          console.log(this.data);
          let size=this.data.length;
          for(let i=0;i<size;i++){
            if(data[i].type===1){
              this.data[i].type='图像分类'
            } else{
              this.data[i].type='图像检索'
            }
            if(data[i].state===1){
              this.data[i].state='未发布'
            }
            else if(data[i].state===2){
              this.data[i].state='审核中'
            }else{
              this.data[i].state='已发布'
            }
          }
        },
        evaluateModel(){
          this.$router.push('/admin/evaluate')
        }
      }
    }
</script>

<style scoped>

</style>
